function getHTTPRequest()
{
    var HTTPRequest;
    if(window.XMLHttpRequest)
    {
        HTTPRequest = new XMLHttpRequest();
        if(HTTPRequest.overrideMimeType)
        {
            HTTPRequest.overrideMimeType('text/html');
        }
    }
    else
    {
        if(window.ActiveXObject)
        {
            try
            {
                HTTPRequest = new ActiveXObject('Msxml2.XMLHTTP');
            }
            catch(e)
            {
                try
                {
                    HTTPRequest = new ActiveXObject("Microsoft.XMLHTTP");
                }
                catch(e)
                {
                    HTTPRequest = null;
                }
            }
        }
    }
    return HTTPRequest;
}

function ajaxPostSend(filePath, parameters, callback)
{
    var HTTPRequest = getHTTPRequest();
    if(HTTPRequest == null)
    {
        alert('Erreur : utilisation des fonctionnalités Ajax impossible.');
    }
    else
    {
        HTTPRequest.open('POST', filePath, true);
        HTTPRequest.onreadystatechange = function()
        {
            ajaxPostReceive(HTTPRequest, callback);
        };
        HTTPRequest.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
        
        var parametersString = '';
        for(var k in parameters)
        {
            if(parameters[k] instanceof Array)
            {
                for(var j in parameters[k])
                {
                    parametersString += k + '[]=' + escape(parameters[k][j]) + '&';
                }
            }
            else
            {
                parametersString += k  + '=' + escape(parameters[k]) + '&';
            }
        }
        HTTPRequest.send(parametersString);
    }
}

function ajaxPostReceive(HTTPRequest, callback)
{
    if(HTTPRequest.readyState == 4)
    {
        if(HTTPRequest.status == 200)
        {
            callback(HTTPRequest.responseText);
        }
        else
        {
            alert('Erreur : La requête ne s\'est pas correctement exécutée.');
        }
    }
    return;
}